Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Scoreboard - Bot Script Help

  1. #1

    Default Scoreboard - Bot Script Help

    Hey all!

    A few moons ago Purple and Sor helped me out with this Scoreboard for jvbots.
    Anyway, as it stands under 1.11, human players that join are assigned a "number" as their name on the bot scoreboard. eg "Player 0, player 1 player 2 consequently. etc).

    Now, there was never a way to display real player names on the bot scoreboard (without going to reborn) - which doesn't work well for me with my hosted bot server currently.

    What I would like to therefore do is write a quick script that would extract the data from the ("Player " + $player[local.i].entnum)
    entry (or from elsewhere if appropriate), and tell a player on-screen who they are whenever they enter a new cycled map.
    Eg If a map starts and the scoreboard script assigns this player as "Player 3", then the hud displays a 3 second: "Welcome [Real Name]. You are Player 3 on the Bot Scoreboard" etc.
    I presume this might have to be a script created that is executed from each map's .scr ?

    Any solutions? Don't know how to code it to do this.

    Many thanks, as always.

    Excerpt that I think is relevant...

    Code:
    if ($player[local.i].dmteam != "spectator")
    				{
    					local.t = $player[local.i].dmteam
    					local.active_players++
    					local.p[local.t]++
    
    					if (level.botsc_array == NIL)
    					{
    						local.c = 1
    					}
    					else
    					{
    						local.c = ( level.botsc_array.size + 1 )
    					}
    
    					level.botsc_array[local.c][1] = ("Player " + $player[local.i].entnum)
    
    					level.botsc_array[local.c][2] = local.t
    					level.botsc_array[local.c][3] = ( $player[local.i].killcount + $player[local.i].bot_killcount )
    					level.botsc_array[local.c][4] = $player[local.i].deathcount
    					if ( (isAlive $player[local.i]) )
    						level.botsc_array[local.c][5] = active
    					else
    						level.botsc_array[local.c][5] = dead
    				}


    Full Script, if needed:

    Code:
    /*
    ======================================================
    *** Multiplayer BotScript; Scoreboard for MoH:AA
    ======================================================
    by Sor
    Version: v3.0 r32
    -----------------------------------
    --- CHANGES:
    
     * Redone the entire system
     * New ui scoreboard (ui/bot_scoreboard.urc)
     * Now you can see which bot killed you
     * Keeps track of up to 32 bots (players included)
     * Dead bots/players indicated
     * Use of globalwidgets reduces the cvar use from 90 to 32.
     * Increased efficiency; reduction of lag
     * No more executions from the lib_game.scr script; reduction of lag
     * Player deaths are now displayed and accurately
     * All players get displayed; I cannot display their names 
      (so I display their clientnumber)
     * Scoreboard FULLY viewable by all players on the server 
       (if they have the ui/bot_scoreboard.urc file of course)
    
     Additional Fixes: 
     * Rifle hit/whip sounds as well as the toses_ sound.
    
     Required Edited Scripts:
     - global/jv_bots/spawnhandler_default.scr
     - global/jv_mp_players.scr
    
    -------------------
    --- COPY/EDIT:
    
     A) All files related to the Airborne Server for MoHAA
     are free to be modified in any proportion. For any reason.
     Mods can always be made better :)
    
     B) Keep this heading in this file in any case (modified/original)
     and if you wish, add your own nickname/contact underneath it.
    
     C) If you changed the files in any way, please state so clearly
     when releasing it to the public. I also recommend: marking
     or mentioning what you changed exactly in the modified files.
    
     Feel free to ask me any help regarding problems/bugs
     when playing this Mod or regarding the modification this Mod.
    
    -------------------
    DO NOT TAKE CREDIT FOR OTHER PEOPLE'S WORK!
    EITHER SUBMIT MODIFIED/ORIGINAL WORK WITHOUT CREDIT
    OR JUST CREDIT Sor.
    ---------------------------------------------
    --- CONTACT:
    E-Mail: 	MOHAALennySoldier@hotmail.com
    Webs: 	www.mods-r-us.net | www.mohaairborne.co.cc
    ======================================================
    */
    main:
    
    	if (level.sc_running == 1)
    		end
    
    	level.sc_running = 1
    
    	local.master = spawn ScriptMaster
    	local.master aliascache toses_ sound/default.wav soundparms 0 0 0 0 0 0 auto loaded maps "m dm obj moh train "
    	local.master aliascache rifle_whip1 sound/weapons/foley/PistolWhip1.wav soundparms 1.0 0.1 0.95 0.1 250 1000 auto loaded maps "m dm obj moh train "
    	local.master aliascache rifle_whip2 sound/weapons/foley/PistolWhip2.wav soundparms 1.0 0.1 0.95 0.1 250 1000 auto loaded maps "m dm obj moh train "
    	local.master aliascache rifle_hit1 sound/weapons/foley/PistolHit1.wav soundparms 1.5 0.0 0.95 0.1 250 1000 auto loaded maps "m dm obj moh train "
    	local.master aliascache rifle_hit2 sound/weapons/foley/PistolHit2.wav soundparms 1.5 0.0 0.95 0.1 250 1000 auto loaded maps "m dm obj moh train "
    	local.master aliascache rifle_hit3 sound/weapons/foley/PistolHit3.wav soundparms 1.5 0.0 0.95 0.1 250 1000 auto loaded maps "m dm obj moh train "
    
    	wait 2.5
    
    	while(1)
    	{
    		if (level.jvbot_jv_mp_ai_running == 1 && level.bots > 0 && $player.size >= 1)
    		{
    			// Number of scores we can display; 16 each team
    			level.score_display_size = 32
    
    			// Reset array
    			level.botsc_array = NIL
    
    			// First check active players
    			local.p["axis"] = 0
    			local.p["allies"] = 0
    			local.active_players = 0
    			for (local.i = 1; local.i <= $player.size; local.i++)
    			{
    				if ($player[local.i].killcount == NIL)
    					$player[local.i].killcount = 0
    
    				if ($player[local.i].bot_killcount == NIL)
    					$player[local.i].bot_killcount = 0
    
    				if ($player[local.i].deathcount == NIL)
    					$player[local.i].deathcount = 0
    
    				if ($player[local.i].dmteam != "spectator")
    				{
    					local.t = $player[local.i].dmteam
    					local.active_players++
    					local.p[local.t]++
    
    					if (level.botsc_array == NIL)
    					{
    						local.c = 1
    					}
    					else
    					{
    						local.c = ( level.botsc_array.size + 1 )
    					}
    
    					level.botsc_array[local.c][1] = ("Player " + $player[local.i].entnum)
    
    					level.botsc_array[local.c][2] = local.t
    					level.botsc_array[local.c][3] = ( $player[local.i].killcount + $player[local.i].bot_killcount )
    					level.botsc_array[local.c][4] = $player[local.i].deathcount
    					if ( (isAlive $player[local.i]) )
    						level.botsc_array[local.c][5] = active
    					else
    						level.botsc_array[local.c][5] = dead
    				}
    			}
    
    			level.score_display_size -= local.active_players
    
    			// Check number of active bots per team
    			local.b["allies"] = 0
    			local.b["axis"] = 0
    			local.active_bots = 0
    
    			local.temp = 0
    			for (local.i = 1; local.i <= (level.score_display_size + local.temp) && local.i <= level.botnum; local.i++)
    			{
    				if (level.botstate[local.i] != "away" && level.botname[local.i] != NIL )
    				{
    					if (level.botsc_array == NIL)
    					{
    						local.c = 1
    					}
    					else
    					{
    						local.c = ( level.botsc_array.size + 1 )
    					}
    	
    					level.botsc_array[local.c][1] = level.botname[local.i]
    					level.botsc_array[local.c][2] = level.botteam[local.i]
    					level.botsc_array[local.c][3] = level.sc_kills[local.i]
    					level.botsc_array[local.c][4] = level.sc_deaths[local.i]
    					level.botsc_array[local.c][5] = level.botstate[local.i]
    	
    					local.t = level.botteam[local.i]
    					local.b[local.t]++
    					local.active_bots++
    				}
    				else
    				{
    					if ( (level.score_display_size + local.temp) < level.botnum)
    					{
    						local.temp++
    					}
    				}
    			}
    
    			level.score_display_size -= local.active_bots
    
    			// Get all scores:
    			local.kills["axis"] = 0
    			local.kills["allies"] = 0
    			local.deaths["axis"] = 0
    			local.deaths["allies"] = 0
    
    			for (local.i = 1; local.i <= level.botsc_array.size; local.i++)
    			{
    				local.t = level.botsc_array[local.i][2]
    				local.kills[local.t] += level.botsc_array[local.i][3]
    				local.deaths[local.t] += level.botsc_array[local.i][4]
    			}
    
    			if (local.kills["axis"] > local.kills["allies"])
    			{	
    				local.winning = "axis"
    			}a
    			else if (local.kills["axis"] < local.kills["allies"])
    			{
    				local.winning = "allies"
    			}	
    			else if (local.kills["axis"] == local.kills["allies"])
    			{
    				if (local.deaths["axis"] < local.deaths["allies"])
    				{	
    					local.winning = "axis"
    				}
    				else if (local.deaths["axis"] > local.deaths["allies"])
    				{	
    					local.winning = "allies"
    				}
    				else if (local.deaths["axis"] == local.deaths["allies"])
    				{
    					local.winning = "allies"
    				}
    			}
    
    			// start the bubble sort function
    			//[1] = name
    			//[2] = team
    			//[3] = kills
    			//[4] = deaths
    			//[5] = state
    			for (local.i = 1; local.i <= level.botsc_array.size; local.i++)
    			{
    				for ( local.j = 1; local.j <= (level.botsc_array.size - local.i); local.j++)
    				{
    					if ( level.botsc_array[local.i][3] >= level.botsc_array[local.i + local.j][3] )
    					{
    						if ( level.botsc_array[local.i][3] == level.botsc_array[local.i + local.j][3] )
    						{
    				 			if ( level.botsc_array[local.i][4] > level.botsc_array[local.i + local.j][4] )
    							{
    								//switch information
    								for (local.f = 1; local.f <= 5; local.f++)
    								{
    									local.temp = level.botsc_array[local.i][local.f]
    									level.botsc_array[local.i][local.f] = level.botsc_array[local.i + local.j][local.f]
    									level.botsc_array[local.i + local.j][local.f] = local.temp
    								}
    							}
    						}
    					}
    					else
    					{
    						//switch information
    						for (local.f = 1; local.f <= 5; local.f++)
    						{
    							local.temp = level.botsc_array[local.i][local.f]
    							level.botsc_array[local.i][local.f] = level.botsc_array[local.i + local.j][local.f]
    							level.botsc_array[local.i + local.j][local.f] = local.temp
    						}
    					}
    				}
    			}
    
    			// =====================================================================
    			// Update Scoreboard
    			// ------------------
    			// - Using globalwidgets to do every varying item except the names;
    			//   that's about 32 cvars
    			// - Using globalwidgets to colour names of bots/player 
    			//   who aren't actively playing
    			// - Clearing all unused varying items
    			//
    			// ---> New scoreboard ui
    			// ======================================================================
    			for (local.i = 1; local. i <= $player.size; local.i++)
    			{
    				if (local.winning == "allies")
    				{
    					$player[local.i] stufftext "globalwidgetcommand topteam title Allies"
    					$player[local.i] stufftext "globalwidgetcommand bottomteam title Axis"
    					$player[local.i] stufftext ("globalwidgetcommand topscore title " + local.kills["allies"])
    					$player[local.i] stufftext ("globalwidgetcommand bottomscore title " + local.kills["axis"])
    					$player[local.i] stufftext ("globalwidgetcommand topkilled title " + local.deaths["allies"])
    					$player[local.i] stufftext ("globalwidgetcommand bottomkilled title " + local.deaths["axis"])
    					waitframe
    				}
    				else
    				{
    					$player[local.i] stufftext "globalwidgetcommand topteam title Axis"
    					$player[local.i] stufftext "globalwidgetcommand bottomteam title Allies"
    					$player[local.i] stufftext ("globalwidgetcommand topscore title " + local.kills["axis"])
    					$player[local.i] stufftext ("globalwidgetcommand bottomscore title " + local.kills["allies"])
    					$player[local.i] stufftext ("globalwidgetcommand topkilled title " + local.deaths["axis"])
    					$player[local.i] stufftext ("globalwidgetcommand bottomkilled title " + local.deaths["allies"])
    					waitframe
    				}
    
    				local.w = 0
    				local.z = 0
    				for (local.f = 1; local.f <= level.botsc_array.size; local.f++)
    				{
    					if (level.botsc_array[local.f][2] == local.winning)
    					{
    						local.w++
    						$player[local.i] stufftext ("set botsc_up" + local.w + " " + level.botsc_array[local.f][1])
    						if (level.botsc_array[local.f][5] != active)
    							$player[local.i] stufftext ("globalwidgetcommand botsc_up" + local.w + " fgcolor 0.70 0.60 0.05 1.00")
    						else
    							$player[local.i] stufftext ("globalwidgetcommand botsc_up" + local.w + " fgcolor 1.00 1.00 1.00 1.00")
    					}
    					else 
    					{
    						local.z++
    						$player[local.i] stufftext ("set botsc_down" + local.z + " " + level.botsc_array[local.f][1])
    						if (level.botsc_array[local.f][5] != active)
    							$player[local.i] stufftext ("globalwidgetcommand botsc_down" + local.z + " fgcolor 0.70 0.60 0.05 1.00")
    						else
    							$player[local.i] stufftext ("globalwidgetcommand botsc_down" + local.z + " fgcolor 1.00 1.00 1.00 1.00")
    					}
    				}
    
    				local.w = 0
    				local.z = 0
    				for (local.f = 1; local.f <= level.botsc_array.size; local.f++)
    				{
    					if (level.botsc_array[local.f][2] == local.winning)
    					{
    						local.w++
    						$player[local.i] stufftext ("globalwidgetcommand botk_up" + local.w + " title " + level.botsc_array[local.f][3])
    						$player[local.i] stufftext ("globalwidgetcommand botd_up" + local.w + " title " + level.botsc_array[local.f][4])	
    						waitframe				
    					}
    					else 
    					{
    						local.z++
    						$player[local.i] stufftext ("globalwidgetcommand botk_down" + local.z + " title " + level.botsc_array[local.f][3])
    						$player[local.i] stufftext ("globalwidgetcommand botd_down" + local.z + " title " + level.botsc_array[local.f][4])
    						waitframe
    					}
    				}
    
    				for (local.o = (local.w + 1); local.o <= 16; local.o++)
    				{
    					if ( (getcvar ("botsc_up" + local.o)) != "" && (getcvar ("botsc_up" + local.o)) != ".")
    					{
    						//setcvar ("botsc_up" + local.o) ""
    						$player[local.i] stufftext ("set botsc_up" + local.o + " .")
    						$player[local.i] stufftext ("globalwidgetcommand botk_up" + local.o + " title .")
    						$player[local.i] stufftext ("globalwidgetcommand botd_up" + local.o + " title .")
    						$player[local.i] stufftext ("globalwidgetcommand botsc_up" + local.o + " fgcolor 1.00 1.00 1.00 1.00")
    						waitframe
    					}
    				}
    
    				for (local.o = (local.z + 1); local.o <= 16; local.o++)
    				{
    					if ( (getcvar ("botsc_down" + local.o)) != "" && (getcvar ("botsc_down" + local.o)) != ".")
    					{
    						//setcvar ("botsc_down" + local.o) ""
    						$player[local.i] stufftext ("set botsc_down" + local.o + " .")
    						$player[local.i] stufftext ("globalwidgetcommand botk_down" + local.o + " title .")
    						$player[local.i] stufftext ("globalwidgetcommand botd_down" + local.o + " title .")
    						$player[local.i] stufftext ("globalwidgetcommand botsc_down" + local.o + " fgcolor 1.00 1.00 1.00 1.00")
    						waitframe
    					}
    				}
    
    			}
    		}
    
    		wait 0.4
    	}
    
    end
    Last edited by OhGaz; September 24th, 2015 at 09:41 AM.

  2. #2

    Default

    Hmm. Well I see "level.botsc_array[local.c][1] = ("Player " + $player[local.i].entnum)". Your script could be executed from DMPrecache and would run on every map. Try something like this..

    In DMPrecache.scr

    exec global/test.scr

    Then in global write a test.scr that's maybe like...

    main:
    Wait 3
    iprintln "test running...."
    Wait 10
    iprintln (level.botsc_array[local.c][1])
    //the only problem is I can't remember how to print a variable like that
    //it may be something like iprintln "sometext" + (level.botscblahblahblah)
    end


    Or you could just test from your map script for now. Either way if you could use that variable it would display what you want, then you'd just have to make a hud or print script for how you want it displayed.

    Edit:: don't forget to have bot scoreboard running or that variable won't exist lol
    Last edited by Gotcha; September 24th, 2015 at 12:46 PM.

  3. #3

    Default

    Thanks Gotcha, but unfortunately couldn't work out how to run that - was getting "Testing running" of course on the screen, but then just "NIL" as an output slightly after.

    Any other ideas from you awesome cats?

    Hoping to display a message to all clients when they join that says "you are Player 0 on the Bot Scoreboard" (based on the scoreboard script written above), as the current configuartion with bots does not allow players to have their "Real name", it displays their client ID as "Player x" on the board. So I want to tell each individual clients "who they are"....

    Cheers and thanks as always,
    OhGaz
    Last edited by OhGaz; September 29th, 2015 at 07:29 AM.

  4. #4

    Default

    I wasn't sure it'd print since it's an array.

    Try changing it to

    iprintln "You are player: " ($player[local.i].entnum)

    I can tell you how to make it say the players name on the scoreboard (with reborn of course lol) but I'm not too savvy on bots. Maybe in the bot scoreboard script make your own variable, like

    level.current = $player[local.i].entnum

    Then do an iprintln "You are: " (level.current) or something.


    EDIT:: Gaz I can say the above works, ($player[local.i].entnum). I put one in my for loop on a test script I'm working on. I didn't set it as a variable or anything, just the red part.

    when I walked into the trigger on 1 pc as host I was player 0, on other pc it showed player 1. Well, they both popped up but I think that's from a problem in my script, but it shows which player is which. All you gotta do is print it however or give it a sexy huddraw. Lol
    Last edited by Gotcha; September 29th, 2015 at 01:46 PM.

  5. #5

    Default

    You nailed it, Gotcha. Thanks! I had an error in my entry for the script. I had "($player[local.i] + entnum)" for some weird reason.

    Fixed now - thanks mate. This will make things a little easier for player identification. I'll pretty it up with a huddraw, indeed.

    WOOT! Another Server problem solved. Now...only a couple more to go. Cheers!

  6. #6

    Default

    Hello - back again on this scoreboard name question....

    So i wrote up a huddraw for the above, but any suggestions as to how to get it working in dmprecache?

    ie - it works fine if I execute it from the map script, but if I execute from dmprecache under "waittill spawn", the result onscreen is "NIL", presumably because the player is not assigned a number until they join.....

    I'm trying to avoid having to put call this new script in all my custom map scripts etc....

    Cheers and many thanks.

    Code:
    main:
    
    local.scoreboardname = ($player[local.i].entnum)
    local.scoreboardname2 = "You are Player: " + local.scoreboardname
    
    while(1)
    {
    huddraw_virtualsize 200 1
    huddraw_font 251 "handle-16"
    huddraw_align 251 "left" "bottom"
    huddraw_rect 251 60 -30 100 100
    huddraw_string 251 local.scoreboardname2
    huddraw_color 251 1 1 1
    huddraw_alpha 251 1
    
    wait 1
    
    }
    
    end
    Last edited by OhGaz; October 2nd, 2015 at 01:07 AM.

  7. #7

    Default

    The 2 variables you set, local.scoreboadname and local.scoreboardname2, put those in the while loop and let me know what happens.

    Also in your DMPrecache, you said you did it under "waittill spawn", do you have an "end" above this waittill spawn? Script may just be rolling right through it. I've never had any luck having something loaded via DMPrecache actually waiting. You could use the spawn detection in admin pro, run your script from the spawn protection script and add a check to keep it from running at every spawn, so it only runs on the first spawn.

    Also probably not important but you're using two index numbers, 200 and 251.

  8. #8

    Default

    The ppoblem you getting the NIL is you dont have the variables executing every time only executes one time when you load the map but if you put inside of the loop you get player when he join.

    I have put here the code for only the map you whant the script to run.

    For the part to olny run on the spawn you can use the spawn event of reborn.

    Code:
    main:
    
    local.map = getcvar(mapname)
    
    switch(local.map)
    {
    
    case "mapyouwhant":
                                    while(1)
    {
    local.scoreboardname = ($player[local.i].entnum)
    local.scoreboardname2 = "You are Player: " + local.scoreboardname
    
    huddraw_virtualsize 200 1
    huddraw_font 251 "handle-16"
    huddraw_align 251 "left" "bottom"
    huddraw_rect 251 60 -30 100 100
    huddraw_string 251 local.scoreboardname2
    huddraw_color 251 1 1 1
    huddraw_alpha 251 1
    
    wait 1
    
    }
    
    break
    }
    end
    EDIT: I was looking now on my post and i have see the number of the index of virtualsize is not same as the others variables you have put wrong or you whant like that?
    Last edited by DoubleKill; October 2nd, 2015 at 09:11 AM.

  9. #9
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    You are getting NIL because local.i has not been defined. Also, don't forget that unlike the ihuddraw command, which is unicasted, the huddraw command is broadcasted.
    This means every client connected to your server will have the same elements displayed on their HUD.

    The only alternative on 1.11 servers is to use globalwidgetcommand. In fact, this is what I use to display the scoreboard to a single player. The problem is that I had to
    create the widgets for that myself. Anyone who does not have the .pk3 will not be able to see the scoreboard. This is why the bot scoreboard is inherently a client-side mod.

    Anyway, there are only three built-in widgets you can use: dday1, dday2 and credits1. This means you can only display three things at once on the HUD of a single client.
    Each widget consists of a menu and a content wrapper. Both of which need to be set up first. In the following snippets, assume self is a player entity.

    self stufftext "globalwidgetcommand dday1 fgcolor 1.00 1.00 1.00 1.00"
    self stufftext "globalwidgetcommand dday1 bgcolor 0.50 0.50 0.50 0.00"
    self stufftext "globalwidgetcommand dday1 fadein 0"
    self stufftext "globalwidgetcommand dday1 menu dday1 640 480 NONE 0"
    self stufftext "globalwidgetcommand dday1 virtualres 0"
    self stufftext "globalwidgetcommand dday1 fullscreen 1"
    self stufftext "globalwidgetcommand dday1 bgfill 0 0 0 1.00"
    
    self stufftext "globalwidgetcommand june6 rect 64 288 512 64"
    self stufftext "globalwidgetcommand june6 fgcolor 1.00 1.00 1.00 1.00"
    self stufftext "globalwidgetcommand june6 bgcolor 0.00 0.00 0.00 0.00"
    self stufftext "globalwidgetcommand june6 font facfont-20"
    self stufftext "globalwidgetcommand june6 shader townhallwindow"


    self stufftext "globalwidgetcommand dday2 shader townhallwindow"
    self stufftext "globalwidgetcommand dday2 fgcolor 1.00 0.00 1.00 1.00"
    self stufftext "globalwidgetcommand dday2 bgcolor 0.00 0.00 0.00 0.00"
    self stufftext "globalwidgetcommand dday2 fadein 0"
    self stufftext "globalwidgetcommand dday2 menu dday2 640 480 NONE 0"
    self stufftext "globalwidgetcommand dday2 virtualres 1"
    self stufftext "globalwidgetcommand dday2 fullscreen 1"
    
    
    self stufftext "globalwidgetcommand charliesector shader townhallwindow"
    self stufftext "globalwidgetcommand charliesector textalign left"
    self stufftext "globalwidgetcommand charliesector rect 280 525 392 64"
    self stufftext "globalwidgetcommand charliesector fgcolor 1.00 3.00 4.00 6.00"
    self stufftext "globalwidgetcommand charliesector bgcolor 0.00 0.00 0.00 0.00"
    self stufftext "globalwidgetcommand charliesector font facfont-20"


    The last global widget you can use is a special one. You have to add those rename statements to make it work because both
    the menu and the content wrapper of this widget are named 'credits1' so there must be a way to tell them apart.

    self stufftext "globalwidgetcommand credits2 name credits1"
    self stufftext "globalwidgetcommand credits1 shader townhallwindow"
    self stufftext "globalwidgetcommand credits1 fgcolor 1.00 0.00 1.00 1.00"
    self stufftext "globalwidgetcommand credits1 bgcolor 0.00 0.00 0.00 0.00"
    self stufftext "globalwidgetcommand credits1 fadein 0"
    self stufftext "globalwidgetcommand credits1 menu credits2 640 480 NONE 0"
    self stufftext "globalwidgetcommand credits1 virtualres 1"
    self stufftext "globalwidgetcommand credits1 fullscreen 1"
    self stufftext "globalwidgetcommand credits1 name credits2"
    
    self stufftext "globalwidgetcommand credits1 shader townhallwindow"
    self stufftext "globalwidgetcommand credits1 textalign left"
    self stufftext "globalwidgetcommand credits1 rect 280 545 392 64"
    self stufftext "globalwidgetcommand credits1 fgcolor 1.00 3.00 4.00 6.00"
    self stufftext "globalwidgetcommand credits1 bgcolor 0.00 0.00 0.00 0.00"
    self stufftext "globalwidgetcommand credits1 font facfont-20"



    At this point, nothing will happen. The widgets are still hidden and configured to display their built-in textures.
    Check pak2.pk3/textures/gametext/ to know what I'm talking about and to know where these things are used in single player.

    So how do we display our own text? Well, we'll have to send the text to the client as a cvar.
    self stufftext ("set mycvar You are player #" + self.entnum)


    Now we can link the content wrapper to display the contents of this cvar.
    self stufftext "globalwidgetcommand june6 linkcvar mycvar"
    // OR
    // self stufftext "globalwidgetcommand charliesector linkcvar mycvar"
    // OR
    // self stufftext "globalwidgetcommand credits1 linkcvar mycvar"


    Finally, we can use showmenu to display the widget and hidemenu to hide it.
    self stufftext "showmenu dday1"
    // OR
    // self stufftext "showmenu dday2"
    // OR
    // self stufftext "showmenu credits1"


    As for the actual problem, try this.
    while(1) {
        for(local.i = 1; local.i <= $player.size; local.i++) {
            local.player = $player[local.i];
            if (!local.player.has_client_id_displayed) {
                local.player.has_client_id_displayed = 1;
    
                local.player stufftext "globalwidgetcommand dday1 fgcolor 1.00 1.00 1.00 1.00"
                local.player stufftext "globalwidgetcommand dday1 bgcolor 0.50 0.50 0.50 0.00"
                local.player stufftext "globalwidgetcommand dday1 fadein 0"
                local.player stufftext "globalwidgetcommand dday1 menu dday1 640 480 NONE 0"
                local.player stufftext "globalwidgetcommand dday1 virtualres 0"
                local.player stufftext "globalwidgetcommand dday1 fullscreen 1"
                local.player stufftext "globalwidgetcommand dday1 bgfill 0 0 0 1.00"
    
                local.player stufftext "globalwidgetcommand june6 rect 64 288 512 64"
                local.player stufftext "globalwidgetcommand june6 fgcolor 1.00 1.00 1.00 1.00"
                local.player stufftext "globalwidgetcommand june6 bgcolor 0.00 0.00 0.00 0.00"
                local.player stufftext "globalwidgetcommand june6 font facfont-20"
                local.player stufftext "globalwidgetcommand june6 shader townhallwindow"
                local.player stufftext ("set client_id_msg You are player #" + local.player.entnum);
                local.player stufftext "globalwidgetcommand june6 linkcvar client_id_msg"
                local.player stufftext "showmenu dday1"
            }
        }
        wait 1
    }

    You'll want to change the display of the widget, though. I don't know how the above will look like.
    Last edited by Sor; October 6th, 2015 at 11:33 AM.
    Morpheus Script (MoH) => You try to shoot yourself in the foot only to discover that MorpheusScript already shot your foot for you.

  10. #10

    Default

    Thank you Gotcha, Doublekill and of course Sor. Always appreciated.

    And Sor, of course! The HUDDRAW is broadcasted! Never tested the client ID script until now with more than one human player - and sure enough it messed up upon two clients joining.

    So with your solution, I will use all 3 widgets likely for:

    1) Client ID - as you have already set out
    2) Bot Kills/Deaths
    3) Human Kills
    As an alternative to 3, maybe "achievements" for Widget 3 - I have been thinking about adding a small achievement system - ala "5 bot kills" "10 bot kills" etc.
    I think that should be feasible based on the $player[local.i].bot_killcount reference in the scoreboard script? I'm not sure...

    Anyway, how do I replicate the client_id one that you built into my next two widgets? I tried, but failed.
    I wasn't sure what I would replace the "client_id_msg" with in the 2nd widget, so I just tried the below:

    Thoughts? Thanks again.

    Code:
    main:
    
    {
    if ($player[local.i].killcount == NIL)
    	$player[local.i].killcount = 0
    
    if ($player[local.i].bot_killcount == NIL)
    	$player[local.i].bot_killcount = 0
    
    if ($player[local.i].deathcount == NIL)
    	$player[local.i].deathcount = 0
    }
    
    while(1) {
        for(local.i = 1; local.i <= $player.size; local.i++) {
            local.player = $player[local.i];
            if (!local.player.has_client_id_displayed) {
                local.player.has_client_id_displayed = 1;
    
    // Widget 1. DISPLAYS CLIENT ID
                local.player stufftext "globalwidgetcommand dday1 fgcolor 1.00 1.00 1.00 1.00"
                local.player stufftext "globalwidgetcommand dday1 bgcolor 0.00 0.00 0.00 0.00"
                local.player stufftext "globalwidgetcommand dday1 fadein 1"
                local.player stufftext "globalwidgetcommand dday1 menu dday1 640 480 NONE 0"
                local.player stufftext "globalwidgetcommand dday1 virtualres 0" 
                local.player stufftext "globalwidgetcommand dday1 fullscreen 0"
                local.player stufftext "globalwidgetcommand dday1 bgfill 0 0 0 0.00"
             
                local.player stufftext "globalwidgetcommand june6 rect 64 288 512 64"
                local.player stufftext "globalwidgetcommand june6 fgcolor 1.00 1.00 1.00 1.00"
                local.player stufftext "globalwidgetcommand june6 bgcolor 0.00 0.00 0.00 0.00"
                local.player stufftext "globalwidgetcommand june6 font handle-16"
                local.player stufftext "globalwidgetcommand june6 shader townhallwindow"
                local.player stufftext ("set client_id_msg You are Player: " + local.player.entnum);
                local.player stufftext "globalwidgetcommand june6 linkcvar client_id_msg"
                local.player stufftext "showmenu dday1"
    
    // Widget 2 DISPLAYS BOT KILLS    
                local.player stufftext "globalwidgetcommand dday2 fgcolor 1.00 1.00 1.00 1.00"
                local.player stufftext "globalwidgetcommand dday2 bgcolor 0.00 0.00 0.00 0.00"
                local.player stufftext "globalwidgetcommand dday2 fadein 1"
                local.player stufftext "globalwidgetcommand dday2 menu dday2 640 480 NONE 0"
                local.player stufftext "globalwidgetcommand dday2 virtualres 0" 
                local.player stufftext "globalwidgetcommand dday2 fullscreen 0"
                local.player stufftext "globalwidgetcommand dday2 bgfill 0 0 0 0.00"
             
                local.player stufftext "globalwidgetcommand charliesector 252 -170 -40 100 100"
                local.player stufftext "globalwidgetcommand charliesector fgcolor 1.00 1.00 1.00 1.00"
                local.player stufftext "globalwidgetcommand charliesector bgcolor 0.00 0.00 0.00 0.00"
                local.player stufftext "globalwidgetcommand charliesector font handle-16"
                local.player stufftext "globalwidgetcommand charliesector shader townhallwindow"
                local.player stufftext ("set bot_kill_msg Bot Frags: " + local.player.bot_killcount);
                local.player stufftext "globalwidgetcommand charliesector linkcvar bot_kill_msg"
                local.player stufftext "showmenu dday2"
    
            }
        }
        wait 1
    }
    
    end
    Last edited by OhGaz; October 7th, 2015 at 08:11 AM.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •